package com.example.demo.server3.tool;

import com.example.demo.server3.template.CMPP_CONNECT;
import com.example.demo.server3.template.CMPP_SUBMIT;
import com.example.demo.server3.template.MessageHeader;
import com.example.demo.server3.template.ProtocolTemplate;
import io.netty.buffer.ByteBuf;

public class TemplateTool {
    public static ProtocolTemplate parse(MessageHeader messageHeader, ByteBuf byteBuf){
        int Command_Id = messageHeader.getCommand_Id();
        switch (Command_Id){
            case 0x00000001:
                CMPP_CONNECT cmpp_connect = new CMPP_CONNECT();
                cmpp_connect.setMessageHeader(messageHeader);
                cmpp_connect.structure(byteBuf);
                return cmpp_connect;
            case 0x00000004:
                CMPP_SUBMIT cmpp_submit = new CMPP_SUBMIT();
                cmpp_submit.setMessageHeader(messageHeader);
                cmpp_submit.structure(byteBuf);
            default:
                return null;
        }
    }

}
